<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateOrderCoupon extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_coupon', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopId')->comment('门店id')->default(0);
            $table->unsignedBigInteger('orderId')->default(0)->comment("订单 ID");
            $table->unsignedBigInteger('customerCouponId')->default(0)->comment("用户关联优惠券 Id");
            $table->unsignedBigInteger('couponId')->default(0)->comment("原始优惠券ID");
            $table->tinyInteger("status")->default(0)->comment("0:待核销 1:已使用 2:已撤销");
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");
            $table->index("orderId", "idx_orderId");
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '订单优惠券核销表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_coupon');
    }
}
